Repository navigation
[6.x] Export panels, action menus and UI modals from @craftcms/cp - #20570
Conversation
📚 Storybook previews@craftcms/ui — open Storybook No changed components detected in this Storybook. resources/js — open Storybook No changed components detected in this Storybook. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the expanded control-panel API and panel slot update.
No open issues 🎉
What changed in this PR
Expands @craftcms/cp so plugin-built screens, including Commerce’s new order editor, can reuse core control-panel features without copying code or importing internal source files.
Changes:
- Exports panel, metadata, activity, action-menu, HTML-rendering, and UI-modal utilities with related types.
- Adds a typed
activeslot prop toScreenPanel, enabling content to load when its panel opens. - Documents the public exports and slot addition in the changelog.
| File | Description |
|---|---|
resources/js/cp-module.ts |
Exposes additional components, UI helpers, and types to plugins. |
resources/js/common/components/ScreenPanel.vue |
Passes the panel’s open state to its default slot. |
CHANGELOG-WIP.md |
Documents the expanded plugin API and active slot prop. |
Review effort: Balanced
brianjhanson
left a comment
There was a problem hiding this comment.
I'm torn on if we should just export everything for plugin authors. On the one hand, I'm sure that would be useful. On the other hand, I'm sure that would be somewhat "dangerous" at least from a perspective of what we're on the hook to support down the line.
|
@brianjhanson yea, probably a month or so ago I think I had something in one of the PRs that exposed everything but had exactly this thought. It is a bit of a catch 22 because not sure what you need until you don't have it at your disposal. |
|
Opened #20608 which exposes a whole lot more. |
Description
Plugin pages that build their own screens can import components and composables from
@craftcms/cp, but a handful of pieces core already uses for its own screens weren't exported. Commerce's new order edit screen needs them, and without the exports a plugin has to copy them or reach into core's source.This exports them from
cp-module.ts:ScreenPanel, to add a panel to a screen's details columnMetadataDetails, the details column's Info panelActivityTimeline, an element's activity and commentsElementActionMenu, an element's actions from itsactionMenuDescriptors()openUiModal()andUiModalOptions, to open a server-defined UI form in a dialogScreenPanel's default slot also receives anactiveprop now, true while its panel is open. A panel can use it to load its content only once someone opens it, which the activity timeline needs. Existing uses ofScreenPaneldon't pass anything to the slot, so they're unaffected.Related issues
craftcms/commerce#4443